//
//  DBHelper+Merge_MineAndFavor.h
//  KidReading
//
//  Created by YangShuai on 17/2/20.
//  Copyright © 2017年 刘赞黄Telen. All rights reserved.
//

#import "DBHelper.h"
#import "DBHelper+Reader.h"

typedef enum : NSUInteger{
    MergeType_Mine = 1,
    MergeType_Favor,
    MergeType_Audio,
}MergeType;

typedef enum : NSInteger{
    TempType_ADD = 1,
    TempType_MINUS,
}TempType;

//我的图书
@interface TABLE_BOOKS_MergeMineANDFavor : TABLE_base
@property(nonatomic,assign)NSInteger userId;
@property(nonatomic,assign)NSInteger bookId;
@property(nonatomic,assign)NSInteger mergeType;
@property(nonatomic,strong)NSString* bookInfoStr;
@end

//我的图书缓存表(用户记录离线删除或者添加的数据)
@interface TABLE_BOOKS_MergeMineANDFavor_TEMP : TABLE_base
@property(nonatomic,assign)NSInteger userId;
@property(nonatomic,assign)NSInteger bookId;
@property(nonatomic,assign)NSInteger mergeType;
@property(nonatomic,strong)NSString* bookInfoStr;
@property(nonatomic,assign)NSInteger tempType;
@end

//记录服务器时间戳
@interface TABLE_BOOKS_MergeTimestamp : TABLE_base
@property(nonatomic,assign)NSInteger userId;
@property(nonatomic,assign)NSInteger mergeType;
@property(nonatomic,assign)long long server_timestamp;
@end

//记录播放列表顺序
@interface TABLE_BOOKS_AudioSort : TABLE_base
@property(nonatomic,assign)NSInteger userId;
@property(nonatomic,strong)NSString* listSortString;
@end

@interface DBHelper (Merge_MineAndFavor)
//
@property(nonatomic,strong)JRFMDatabaseQueue* mergeMineAndFavor_dbQue;
//对于我的图书或者我的收藏的操作
//添加我的图书或者我的收藏数据
- (void)Merge_MineAndFavor_updateListWithIsTempTable:(BOOL)isTampTable dictArr:(NSArray*)dictList complete:(void (^)(void))comp;
- (void)Merge_MineAndFavor_updateListWithIsTempTable:(BOOL)isTampTable tbArr:(NSArray*)tbList complete:(void (^)(void))comp;
//删除的图书或者我的收藏数据
- (void)Merge_MineAndFavor_deletListWithIsTempTable:(BOOL)isTampTable dictArr:(NSArray*)dictList complete:(void (^)(void))comp;
- (void)Merge_MineAndFavor_deletListWithIsTempTable:(BOOL)isTampTable tbArr:(NSArray*)tbList complete:(void (^)(void))comp;
//查询的图书或者我的收藏数据
- (void)Merge_MineAndFavor_getDictList:(void(^)(NSArray* list))retlist WithIsTempTable:(BOOL)isTampTable where:(NSString*)wheresql;
- (void)Merge_MineAndFavor_getList:(void(^)(NSArray* list))retlist WithIsTempTable:(BOOL)isTampTable where:(NSString*)wheresql;

//对于时间戳的操作
- (void)Merge_MineAndFavor_updateMergeTimestampWithNewTimestamp:(long long)newTimestamp MergeType:(MergeType)mergeType completed:(void (^)(void))comp;
- (void)Merge_MineAndFavor_deleteUserMergeTimestampWithMergeType:(MergeType)mergeType Completed:(void (^)(void))comp;
- (void)Merge_MineAndFavor_getUserMergeTimestampWithMergeType:(MergeType)mergeType Completed:(void(^)(long long timestamp))comp;

//对于audiosort的操作
- (void)Merge_MineAndFavor_updateAudioSortWithSortStr:(NSString*)sortStr completed:(void (^)(void))comp;
- (void)Merge_MineAndFavor_deleteAudioSortWithSortStr:(NSString*)sortStr Completed:(void (^)(void))comp;
- (void)Merge_MineAndFavor_getAudioSortCompleted:(void(^)(NSString* sortStr))comp;
@end
